package com.nmsl.registration.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nmsl.common.annotation.Log;
import com.nmsl.common.core.controller.BaseController;
import com.nmsl.common.core.domain.AjaxResult;
import com.nmsl.common.enums.BusinessType;
import com.nmsl.registration.domain.skxPrescriptionInfo;
import com.nmsl.registration.service.IskxPrescriptionInfoService;
import com.nmsl.common.utils.poi.ExcelUtil;
import com.nmsl.common.core.page.TableDataInfo;

/**
 * 患者处方信息Controller
 * 
 * @author skx
 * @date 2025-02-24
 */
@RestController
@RequestMapping("/registration/skxprescriptionInfo")
public class skxPrescriptionInfoController extends BaseController
{
    @Autowired
    private IskxPrescriptionInfoService skxPrescriptionInfoService;

    /**
     * 查询患者处方信息列表
     */
    @PreAuthorize("@ss.hasPermi('registration:skxprescriptionInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(skxPrescriptionInfo skxPrescriptionInfo)
    {
        startPage();
        List<skxPrescriptionInfo> list = skxPrescriptionInfoService.selectskxPrescriptionInfoList(skxPrescriptionInfo);
        return getDataTable(list);
    }

    /**
     * 导出患者处方信息列表
     */
    @PreAuthorize("@ss.hasPermi('registration:skxprescriptionInfo:export')")
    @Log(title = "患者处方信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, skxPrescriptionInfo skxPrescriptionInfo)
    {
        List<skxPrescriptionInfo> list = skxPrescriptionInfoService.selectskxPrescriptionInfoList(skxPrescriptionInfo);
        ExcelUtil<skxPrescriptionInfo> util = new ExcelUtil<skxPrescriptionInfo>(skxPrescriptionInfo.class);
        util.exportExcel(response, list, "患者处方信息数据");
    }

    /**
     * 获取患者处方信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('registration:skxprescriptionInfo:query')")
    @GetMapping(value = "/{visitRecordId}")
    public AjaxResult getInfo(@PathVariable("visitRecordId") Long visitRecordId)
    {
        return success(skxPrescriptionInfoService.selectskxPrescriptionInfoByPrescriptionInfoId(visitRecordId));
    }

    /**
     * 新增患者处方信息
     */
    @PreAuthorize("@ss.hasPermi('registration:skxprescriptionInfo:add')")
    @Log(title = "患者处方信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody skxPrescriptionInfo skxPrescriptionInfo)
    {
        return toAjax(skxPrescriptionInfoService.insertskxPrescriptionInfo(skxPrescriptionInfo));
    }

    /**
     * 修改患者处方信息
     */
    @PreAuthorize("@ss.hasPermi('registration:skxprescriptionInfo:edit')")
    @Log(title = "患者处方信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody skxPrescriptionInfo skxPrescriptionInfo)
    {
        return toAjax(skxPrescriptionInfoService.updateskxPrescriptionInfo(skxPrescriptionInfo));
    }

    /**
     * 删除患者处方信息
     */
    @PreAuthorize("@ss.hasPermi('registration:skxprescriptionInfo:remove')")
    @Log(title = "患者处方信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{prescriptionInfoIds}")
    public AjaxResult remove(@PathVariable Long[] prescriptionInfoIds)
    {
        return toAjax(skxPrescriptionInfoService.deleteskxPrescriptionInfoByPrescriptionInfoIds(prescriptionInfoIds));
    }
}
